<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/file-upload.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/GroupSummary.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/RowExpander.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/EditableItem.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/RangeMenu.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/GridFilters.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/Filter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/StringFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/ListFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/form/FileUploadField.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/selectBiFactory.js">
        </script>
        <script type="text/javascript" src="../../scripts/selectBiFranceCustomer.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
        <script type="text/javascript">
            var azMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.accessoryzip');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
            
            var ctMailleXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtMaille');
            var ctZipTypeXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtZipType');
            var ctZipSizeXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtZipSize');
            var ctWeaveTypeXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtWeaveType');
            var ctPullerXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtPuller');
            var ctSliderXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtSlider');
            var ctYesnoXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtYesno');
            var customerXmlLoader = new xmlLoader('../../servlet/BiFranceCustomerServlet?action=5');
            var factoryXmlLoader = new xmlLoader('../../servlet/BiFactoryServlet?action=5');
            var ctSupplyTypeXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtSupplyType');
            
            var ctMailleStore;
            var ctZipTypeStore;
            var ctZipSizeStore;
            var ctWeaveTypeStore;
            var ctPullerStore;
            var ctSliderStore;
            var ctYesnoStore;
            var customerStore;
            var factoryStore;
            var ctSupplyTypeStore;
            
            var ctMailleCombo;
            var ctZipTypeCombo;
            var ctZipSizeCombo;
            var ctWeaveTypeCombo;
            var ctPullerCombo;
            var ctSliderCombo;
            var ctSupplyTypeCombo;
            //var customerCombo;
            //var factoryCombo;
            
            var selectedFactory;
            
            var selectFactoryCallback = function(factoryId, factoryName){
                document.getElementById('factoryId').value = factoryId;
                document.getElementById('factoryNameCN').value = selectedFactory.nameCN;
                document.getElementById('factoryNameEN').value = selectedFactory.nameEN;
            }
            
            var selectFranceCustomerCallback = function(customerId, customerName, customerDepartment){
                document.getElementById('customerId').value = customerId;
                document.getElementById('customerName').value = customerName;
                document.getElementById('customerDepartment').value = customerDepartment;
            }
            
            var onIsSpecialSet = function(){
				var ctSupplyType = ctSupplyTypeCombo.getValue();
				if(ctSupplyType == '01'){
					Ext.getCmp('factoryId').disable();
					Ext.getCmp('factoryNameCN').disable();
					Ext.getCmp('factoryNameEN').disable();
					Ext.getCmp('factoryReference').disable();
					Ext.getCmp('factoryColor').disable();
					
					Ext.getCmp('customerId').enable();
					Ext.getCmp('customerName').enable();
					Ext.getCmp('customerDepartment').enable();
					Ext.getCmp('customerReference').enable();
					Ext.getCmp('customerColor').enable();
				}else if(ctSupplyType == '02'){
					Ext.getCmp('customerId').disable();
					Ext.getCmp('customerName').disable();
					Ext.getCmp('customerDepartment').disable();
					Ext.getCmp('customerReference').disable();
					Ext.getCmp('customerColor').disable();

					Ext.getCmp('factoryId').enable();
					Ext.getCmp('factoryNameCN').enable();
					Ext.getCmp('factoryNameEN').enable();
					Ext.getCmp('factoryReference').enable();
					Ext.getCmp('factoryColor').enable();
				}else{
                	Ext.getCmp('customerId').disable();
                    Ext.getCmp('customerName').disable();
                    Ext.getCmp('customerDepartment').disable();
                    Ext.getCmp('customerReference').disable();
					Ext.getCmp('customerColor').disable();
					
                    Ext.getCmp('factoryId').disable();
                    Ext.getCmp('factoryNameCN').disable();
                    Ext.getCmp('factoryNameEN').disable();
                    Ext.getCmp('factoryReference').disable();
					Ext.getCmp('factoryColor').disable();
                }
			}
			

            
            Ext.onReady(function(){
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'side';
                
                var idValue = getPrarmeterValue(window.location, 'id');
                var startPage = getPrarmeterValue(window.location, 'startPage');
                
                ctMailleStore = new Ext.data.Store({
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, ['code', 'description']),
                    data: ctMailleXmlLoader.getXml()
                });
                
                ctZipTypeStore = new Ext.data.Store({
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, ['code', 'description']),
                    data: ctZipTypeXmlLoader.getXml()
                });
                
                ctZipSizeStore = new Ext.data.Store({
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, ['code', 'description']),
                    data: ctZipSizeXmlLoader.getXml()
                });
                
                ctWeaveTypeStore = new Ext.data.Store({
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, ['code', 'description']),
                    data: ctWeaveTypeXmlLoader.getXml()
                });
                
                ctSliderStore = new Ext.data.Store({
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, ['code', 'description']),
                    data: ctSliderXmlLoader.getXml()
                });
                
                ctPullerStore = new Ext.data.Store({
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, ['code', 'description']),
                    data: ctPullerXmlLoader.getXml()
                });
                
                ctYesnoStore = new Ext.data.Store({
                    reader: new Ext.data.XmlReader({
                        // records will have an "Item" tag
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, ['code', 'description']),
                    data: ctYesnoXmlLoader.getXml()
                });
                
                ctSupplyTypeStore = new Ext.data.Store({
                    reader: new Ext.data.XmlReader({
                        // records will have an "Item" tag
                        record: 'item',
                        id: 'code',
                        totalRecords: 'itemTotal'
                    }, ['code', 'description']),
                    data: ctSupplyTypeXmlLoader.getXml()
                });
                /*            
                 customerStore = new Ext.data.Store({
                 reader: new Ext.data.XmlReader({
                 record: 'item',
                 id: 'id',
                 totalRecords: 'itemTotal'
                 }, ['id', 'name', 'department']),
                 data: customerXmlLoader.getXml()
                 });
                 
                 factoryStore = new Ext.data.Store({
                 reader: new Ext.data.XmlReader({
                 record: 'item',
                 id: 'id',
                 totalRecords: 'itemTotal'
                 }, ['id', 'name']),
                 data: factoryXmlLoader.getXml()
                 });
                 */
                ctMailleCombo = new Ext.form.ComboBox({
                    fieldLabel: azMessage.get('ui.accessoryzip.zipmailletype'),
                    id: 'ctMaille',
                    name: 'ctMaille',
                    allowBlank: false,
                    blankText: message.get('message.edit.noblank'),
                    editable: false,
                    store: ctMailleStore,
                    valueField: 'code',
                    displayField: 'description',
                    triggerAction: 'all',
                    emptyText: message.get('message.combo.pleaseselect'),
                    selectOnFocus: true,
                    mode: 'local'
                });
                
                ctZipTypeCombo = new Ext.form.ComboBox({
                    fieldLabel: azMessage.get('ui.accessoryzip.type'),
                    id: 'ctZipType',
                    name: 'ctZipType',
                    allowBlank: false,
                    blankText: message.get('message.edit.noblank'),
                    editable: false,
                    store: ctZipTypeStore,
                    valueField: 'code',
                    displayField: 'description',
                    triggerAction: 'all',
                    emptyText: message.get('message.combo.pleaseselect'),
                    selectOnFocus: true,
                    mode: 'local',
                    listeners: {
                        select: {
                            fn: function(thisCombo, record, index){
                                setReference();
                                if (thisCombo.getValue() == '01') {
                                    Ext.getCmp('zipLength').enable();
                                    ctWeaveTypeCombo.enable();
                                    ctZipSizeCombo.enable();
                                    ctMailleCombo.enable();
                                    ctSliderCombo.enable();
                                    
                                    ctPullerCombo.disable();
                                }
                                else 
                                    if (thisCombo.getValue() == '02') {
                                        ctPullerCombo.enable();
                                        
                                        Ext.getCmp('zipLength').enable();
                                        ctWeaveTypeCombo.enable();
                                        ctZipSizeCombo.enable();
                                        ctMailleCombo.enable();
                                        ctSliderCombo.enable();
                                    }
                                    else {
                                        Ext.getCmp('zipLength').disable();
                                        ctWeaveTypeCombo.disable();
                                        ctZipSizeCombo.disable();
                                        ctMailleCombo.disable();
                                        ctSliderCombo.disable();
                                    }
                            }
                        }
                    }
                });
                
                ctZipSizeCombo = new Ext.form.ComboBox({
                    fieldLabel: azMessage.get('ui.accessoryzip.zipsize'),
                    id: 'ctZipSize',
                    name: 'ctZipSize',
                    allowBlank: false,
                    blankText: message.get('message.edit.noblank'),
                    editable: false,
                    store: ctZipSizeStore,
                    valueField: 'code',
                    displayField: 'description',
                    triggerAction: 'all',
                    emptyText: message.get('message.combo.pleaseselect'),
                    selectOnFocus: true,
                    mode: 'local'
                });
                
                ctWeaveTypeCombo = new Ext.form.ComboBox({
                    fieldLabel: azMessage.get('ui.accessoryzip.zipweave'),
                    id: 'ctWeaveType',
                    name: 'ctWeaveType',
                    allowBlank: false,
                    blankText: message.get('message.edit.noblank'),
                    editable: false,
                    store: ctWeaveTypeStore,
                    valueField: 'code',
                    displayField: 'description',
                    triggerAction: 'all',
                    emptyText: message.get('message.combo.pleaseselect'),
                    selectOnFocus: true,
                    mode: 'local'
                });
                
                ctPullerCombo = new Ext.form.ComboBox({
                    fieldLabel: azMessage.get('ui.accessoryzip.puller'),
                    id: 'ctPuller',
                    name: 'ctPuller',
                    allowBlank: false,
                    blankText: message.get('message.edit.noblank'),
                    editable: false,
                    store: ctPullerStore,
                    valueField: 'code',
                    displayField: 'description',
                    triggerAction: 'all',
                    emptyText: message.get('message.combo.pleaseselect'),
                    selectOnFocus: true,
                    mode: 'local'
                });
                
                ctSliderCombo = new Ext.form.ComboBox({
                    fieldLabel: azMessage.get('ui.accessoryzip.slider'),
                    id: 'ctSlider',
                    name: 'ctSlider',
                    allowBlank: false,
                    blankText: message.get('message.edit.noblank'),
                    editable: false,
                    store: ctSliderStore,
                    valueField: 'code',
                    displayField: 'description',
                    triggerAction: 'all',
                    emptyText: message.get('message.combo.pleaseselect'),
                    selectOnFocus: true,
                    mode: 'local'
                });
                
                ctSupplyTypeCombo = new Ext.form.ComboBox({
                    fieldLabel: message.get('message.edit.buyer'),
                    id: 'ctSupplyType',
                    name: 'ctSupplyType',
                    allowBlank: false,
                    blankText: message.get('message.edit.noblank'),
                    editable: false,
                    store: ctSupplyTypeStore,
                    valueField: 'code',
                    displayField: 'description',
                    triggerAction: 'all',
                    emptyText: message.get('message.combo.pleaseselect'),
                    selectOnFocus: true,
                    mode: 'local',
                    listeners: {
                        select: {
                            fn: function(thisCombo, record, index){
                                onIsSpecialSet();
                            }
                        }
                    }
                });
                /*
                 customerCombo = new Ext.form.ComboBox({
                 fieldLabel: message.get('message.edit.customername'),
                 id: 'customerId',
                 name: 'customerId',
                 tpl: '<tpl for="."><div class="x-combo-list-item">{name}&nbsp;&nbsp;--&nbsp;&nbsp;{department}</div></tpl>',
                 valueField: 'id',
                 typeAhead: true,
                 store: customerStore,
                 displayField: 'name',
                 forceSelection: true,
                 triggerAction: 'all',
                 emptyText: message.get('message.combo.pleaseselect'),
                 selectOnFocus: true,
                 mode: 'local'
                 });
                 
                 factoryCombo = new Ext.form.ComboBox({
                 fieldLabel: message.get('message.edit.factoryname'),
                 id: 'factoryId',
                 name: 'factoryId',
                 tpl: '<tpl for="."><div class="x-combo-list-item">{name}</div></tpl>',
                 valueField: 'id',
                 typeAhead: true,
                 store: factoryStore,
                 displayField: 'name',
                 forceSelection: true,
                 triggerAction: 'all',
                 emptyText: message.get('message.combo.pleaseselect'),
                 selectOnFocus: true,
                 mode: 'local'
                 });
                 */
                var setReference = function(){
                    if (ctZipTypeCombo.getRawValue() == '' || (Ext.getCmp('zipLength').getValue() == '' && ctZipTypeCombo.getValue() != '03')) {
                        return;
                    }
                    var maxReferenceIndextXmlLoader = new xmlLoader('../../servlet/BiAccessoryZipServlet?action=10&ctZipType=' + ctZipTypeCombo.getValue());
                    var maxIndex = maxReferenceIndextXmlLoader.getValueByTagName('item');
                    document.getElementById('referenceIndex').value = maxIndex;
                    var reference = '';
                    if (ctZipTypeCombo.getValue() == '01') {
                        reference = 'Z-';
                    }
                    else 
                        if (ctZipTypeCombo.getValue() == '02') {
                            reference = 'ZP-';
                        }
                        else {
                            reference = 'PZ-';
                        }
                    
                    reference += maxIndex;
                    if (ctZipTypeCombo.getValue() != '03') {
                        reference += '-' + Ext.getCmp('zipLength').getValue();
                    }
                    Ext.getCmp('reference').setValue(reference);
                }
                
                var accessoryZipForm = new Ext.FormPanel({
                    fileUpload: true,
                    labelAlign: 'left',
                    url: '../../servlet/BiAccessoryZipServlet?action=1',
                    frame: true,
                    title: azMessage.get('ui.accessoryzip.edittitle'),
                    bodyStyle: 'padding:5px 5px 5px 5px;margin-top: 2px;',
                    width: '100%',
                    labelWidth: 105,
                    reader: new Ext.data.XmlReader({
                        record: 'item'
                    }, [{
                        name: 'id',
                        mapping: 'id'
                    }, {
                        name: 'photoName',
                        mapping: 'photoName'
                    }, {
                        name: 'reference',
                        mapping: 'reference'
                    }, {
                        name: 'referenceIndex',
                        mapping: 'referenceIndex'
                    }, {
                        name: 'ctZipType',
                        mapping: 'ctZipType'
                    }, {
                        name: 'ctWeaveType',
                        mapping: 'ctWeaveType'
                    }, {
                        name: 'ctZipSize',
                        mapping: 'ctZipSize'
                    }, {
                        name: 'comment',
                        mapping: 'comment'
                    }, {
                        name: 'ctMaille',
                        mapping: 'ctMaille'
                    }, {
                        name: 'ctSupplyType',
                        mapping: 'ctSupplyType'
                    }, {
                        name: 'zipLength',
                        mapping: 'zipLength'
                    }, {
                        name: 'customerId',
                        mapping: 'customerId'
                    }, {
                        name: 'customerName',
                        mapping: 'customerName'
                    }, {
                        name: 'customerDepartment',
                        mapping: 'customerDepartment'
                    }, {
                        name: 'factoryId',
                        mapping: 'factoryId'
                    }, {
                        name: 'factoryNameCN',
                        mapping: 'factoryNameCN'
                    }, {
                        name: 'factoryNameEN',
                        mapping: 'factoryNameEN'
                    }, {
                        name: 'dzColor',
                        mapping: 'dzColor'
                    }, {
                        name: 'customerReference',
                        mapping: 'customerReference'
                    }, {
                        name: 'customerColor',
                        mapping: 'customerColor'
                    }, {
                        name: 'factoryReference',
                        mapping: 'factoryReference'
                    }, {
                        name: 'factoryColor',
                        mapping: 'factoryColor'
                    }, {
                        name: 'ctSlider',
                        mapping: 'ctSlider'
                    }, {
                        name: 'ctPuller',
                        mapping: 'ctPuller'
                    }]),
                    //reader: msItemXMLReader,
                    items: [{
                        id: 'id',
                        name: 'id',
                        xtype: 'hidden'
                    }, {
                        id: 'photoName',
                        name: 'photoName',
                        xtype: 'hidden'
                    }, {
                        id: 'customerId',
                        name: 'customerId',
                        xtype: 'hidden'
                    }, {
                        id: 'factoryId',
                        name: 'factoryId',
                        xtype: 'hidden'
                    }, {
                        id: 'referenceIndex',
                        name: 'referenceIndex',
                        xtype: 'hidden'
                    }, {
                        xtype: 'fieldset',
                        collapsible: true,
                        title: azMessage.get('ui.accessoryzip.set1'),
                        autoHeight: true,
                        items: [{
                            layout: 'column',
                            items: [{
                                columnWidth: .5,
                                layout: 'form',
                                items: [ctZipTypeCombo, {
                                    id: 'customerName',
                                    name: 'customerName',
                                    fieldLabel: message.get('message.edit.customername'),
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    allowBlank: false,
                                    blankText: message.get('message.edit.noblank'),
                                    emptyText: message.get('message.combo.pleaseselect'),
                                    readOnly: true,
                                    maxLength: 64,
                                    listeners: {
                                        'render': {
                                            fn: function(){
                                                Ext.getCmp('customerName').getEl().on('click', function(){
                                                    selectFranceCustomer(selectFranceCustomerCallback);
                                                }, this);
                                            },
                                            scope: this
                                        }
                                    }
                                }, {
                                    xtype: 'textfield',
                                    fieldLabel: fcMessage.get('ui.francecustomer.department'),
                                    id: 'customerDepartment',
                                    name: 'customerDepartment',
                                    anchor: '86%',
                                    allowBlank: true,
                                    blankText: message.get('message.edit.noblank'),
                                    readOnly: true,
                                    maxLength: 64,
                                    tabIndex: 1
                                }, {
                                    name: 'customerReference',
                                    id: 'customerReference',
                                    fieldLabel: azMessage.get('ui.accessoryzip.customerreference'),
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                }, {
                                    name: 'customerColor',
                                    id: 'customerColor',
                                    fieldLabel: azMessage.get('ui.accessoryzip.customercolor'),
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                }, {
                                    xtype: 'numberfield',
                                    fieldLabel: azMessage.get('ui.accessoryzip.length') + '(cm)',
                                    id: 'zipLength',
                                    name: 'zipLength',
                                    anchor: '86%',
                                    allowBlank: false,
                                    blankText: message.get('message.edit.noblank'),
                                    maxLength: 64,
                                    tabIndex: 2
                                }]
                            }, {
                                columnWidth: .5,
                                layout: 'form',
                                items: [ctSupplyTypeCombo, {
                                    id: 'factoryNameCN',
                                    name: 'factoryNameCN',
                                    fieldLabel: fMessage.get('ui.factory.name'),
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    allowBlank: false,
                                    blankText: message.get('message.edit.noblank'),
                                    emptyText: message.get('message.combo.pleaseselect'),
                                    readOnly: true,
                                    maxLength: 128,
                                    listeners: {
                                        'render': {
                                            fn: function(){
                                                Ext.getCmp('factoryNameCN').getEl().on('click', function(){
                                                    selectFactory(selectFactoryCallback);
                                                }, this);
                                            },
                                            scope: this
                                        }
                                    }
                                }, {
                                    id: 'factoryNameEN',
                                    name: 'factoryNameEN',
                                    fieldLabel: '',
                                    labelSeparator:'',
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    allowBlank: false,
                                    readOnly: true,
                                    maxLength: 128
                                }, {
                                    name: 'factoryReference',
                                    id: 'factoryReference',
                                    fieldLabel: azMessage.get('ui.accessoryzip.factoryreference'),
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                }, {
                                    name: 'factoryColor',
                                    id: 'factoryColor',
                                    fieldLabel: azMessage.get('ui.accessoryzip.factorycolor'),
                                    xtype: 'textfield',
                                    anchor: '86%',
                                    //allowBlank: false,
                                    //blankText: message.get('message.edit.noblank'),
                                    maxLength: 64
                                }, {
                                    xtype: 'fileuploadfield',
                                    width: '80%',
                                    id: 'photo',
                                    emptyText: message.get('message.edit.selectimage'),
                                    fieldLabel: message.get('message.edit.photo'),
                                    name: 'photo',
                                    buttonCfg: {
                                        text: '',
                                        iconCls: 'uploadIcon'
                                    }
                                }]
                            }]
                        }]
                    }, {
                        xtype: 'fieldset',
                        collapsible: true,
                        title: azMessage.get('ui.accessoryzip.set2'),
                        autoHeight: true,
                        items: [{
                            layout: 'column',
                            items: [{
                                columnWidth: .5,
                                layout: 'form',
                                items: [ctWeaveTypeCombo, ctMailleCombo, ctPullerCombo]
                            }, {
                                columnWidth: .5,
                                layout: 'form',
                                items: [ctZipSizeCombo, ctSliderCombo]
                            }]
                        }]
                    }, {
                        xtype: 'textfield',
                        fieldLabel: azMessage.get('ui.accessoryzip.reference'),
                        id: 'reference',
                        name: 'reference',
                        anchor: '90%',
                        allowBlank: false,
                        blankText: message.get('message.edit.noblank'),
                        maxLength: 64,
                        tabIndex: 1,
                        listeners: {
                            'render': {
                                fn: function(){
                                    Ext.getCmp('reference').getEl().on('click', function(){
                                        setReference();
                                    }, this);
                                },
                                scope: this
                            }
                        }
                    }, {
                        fieldLabel: message.get('message.edit.comment'),
                        name: 'comment',
                        xtype: 'textarea',
                        maxLength: 512,
                        width: '90%',
                        maxLengthText: message.get('message.edit.toolong')
                    }],
                    
                    buttons: [{
                        text: message.get('message.edit.save'),
                        handler: function(){
                            if (accessoryZipForm.getForm().isValid()) {
                            
                            	if(idValue == null){
                            		setReference();
                            	}
                            
                                document.getElementsByName('ctMaille')[0].value = ctMailleCombo.getValue();
                                document.getElementsByName('ctZipType')[0].value = ctZipTypeCombo.getValue();
                                document.getElementsByName('ctZipSize')[0].value = ctZipSizeCombo.getValue();
                                document.getElementsByName('ctWeaveType')[0].value = ctWeaveTypeCombo.getValue();
                                document.getElementsByName('ctPuller')[0].value = ctPullerCombo.getValue();
                                document.getElementsByName('ctSlider')[0].value = ctSliderCombo.getValue();
                                document.getElementsByName('ctSupplyType')[0].value = ctSupplyTypeCombo.getValue();
                                //document.getElementsByName('customerId')[0].value = customerCombo.getValue();
                                //document.getElementsByName('factoryId')[0].value = factoryCombo.getValue();
                                
                                accessoryZipForm.getForm().submit({
                                    method: 'post',
                                    success: function(form, action){
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.successful'));
                                        document.getElementById('photo-file').value = null;
                                        accessoryZipForm.getForm().reset();
                                    },
                                    failure: function(form, action){
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.unsuccessful'));
                                    }
                                });
                            }
                        }
                    }, {
                        text: message.get('message.edit.reset'),
                        handler: function(){
                            accessoryZipForm.getForm().reset();
                        }
                    }, {
                        text: message.get('message.edit.cancel'),
                        handler: function(){
                            if (startPage != null) {
                                window.location = 'accessory_zip_list.html?startPage=' + startPage;
                            }
                            else {
                                window.location = 'accessory_zip_list.html';
                            }
                        }
                    }]
                });
                
                accessoryZipForm.render('accessoryZip');
                
                new Ext.Resizable('customImg1', {
                    wrap: true,
                    pinned: true,
                    dynamic: true,
                    handles: 'all',
                    draggable: true
                });
                
                if (idValue != null) {
                    document.getElementById('id').value = idValue;
                    accessoryZipForm.getForm().load({
                        url: '../../servlet/BiAccessoryZipServlet?action=3&id=' + idValue,
                        waitMsg: Ext.LoadMask.prototype.msg,
                        success: function(form, action){
                            document.getElementById('customImg1').src = '../../_temp/' + document.getElementById('photoName').value;
                            onIsSpecialSet();
                            if (ctZipTypeCombo.getValue() == '01') {
                                Ext.getCmp('zipLength').enable();
                                ctWeaveTypeCombo.enable();
                                ctZipSizeCombo.enable();
                                ctMailleCombo.enable();
                                ctSliderCombo.enable();
                                
                                ctPullerCombo.disable();
                            }
                            else 
                                if (ctZipTypeCombo.getValue() == '02') {
                                    ctPullerCombo.enable();
                                    
                                    Ext.getCmp('zipLength').enable();
                                    ctWeaveTypeCombo.enable();
                                    ctZipSizeCombo.enable();
                                    ctMailleCombo.enable();
                                    ctSliderCombo.enable();
                                }
                                else {
                                    Ext.getCmp('zipLength').disable();
                                    ctWeaveTypeCombo.disable();
                                    ctZipSizeCombo.disable();
                                    ctMailleCombo.disable();
                                    ctSliderCombo.disable();
                                }
                        }
                    });
                }
            });
        </script>
    </head>
    <body>
        <div id="accessoryZip">
        </div>
        <img id="customImg1" src="../../_temp/noimage.gif" style="position: absolute; left: 40%; width: 250px; cursor: move; z-index: 100;"/>
    </body>
</html>